<template>
  <div class="brought">
  <div class="loading" v-if="loading">loading</div>
  <div class="error" v-if="error">error</div>
   <!-- <p v&#45;bind:class="{active:isActive}">{{ brought  }}</p> -->
    <div>
       <tab :line-width=2 active-color='#fc378c' v-model="index">
        <tab-item class="vux-center" :selected="demo2 === item" v-for="(item, index) in list2" @click="doit()" :key="index">     <button @click="doit(item,demo2)">godoit{{item}}</button></tab-item>
      </tab>
      <swiper v-model="index" height="100px" :show-dots="false">
        <swiper-item v-for="(item, index) in list2" :key="index">
          <div class="tab-swiper vux-center">{{item}}

            <p v-for="a in all_bought.body.knowledgeGroupList">
         knowledeglist{{a.knowledgeList}}

         <!-- <h1 v&#45;if="a" v&#45;for="i in a.knowledgeList ">{{i}}</h1> -->
            <!-- <img style="width:100vw; height:400px":src="a.cover" alt=""> -->
            </p>

          </div>
        </swiper-item>
      </swiper>
    </div>
  </div>
</template>
<style lang="less" >
@import '~vux/src/styles/reset.less';
@import '~vux/src/styles/1px.less';
@import '~vux/src/styles/tap.less';

.brought 	{

}
</style>
<script>
import { Tab, Swiper,SwiperItem,TabItem, XButton, TransferDom} from 'vux'
const list = () => ['全部', '知识学堂', '视频学堂', '学习计划']
export default {
  data () {
    return {
    list2: list(),
      demo2: '美食',
      index: 0,
  loading: false,
    post: null,
    error: null,
    brought:false,
    isActive:false,
     broughtlist:{
       actionName:'QueryHaveBoughtKnowledgeGroup',
       url: 'baseapi',
        postData: {
                     'type':'2', //类型1.文字课程，2.查询学习计划（为空时查询全部）
                     'tagId':'XXJH' //标签ID
                   }
     }
    }
  },
  created () {
    this.gobuy()
  },
  directives: {
    TransferDom
  },
  components: {
    Tab, Swiper,SwiperItem,TabItem,
    XButton
  },
  methods: {
    doit(a){
      alert(a)
      console.info(a);
      switch(a) {
          case "学习计划":
          console.info('xxjh');
          let x = {
               actionName:'QueryHaveBoughtKnowledgeGroup',
               url: 'baseapi',
                postData: {
                             'type':'2', //类型1.文字课程，2.查询学习计划（为空时查询全部）
                             'tagId':'XXJH' //标签ID
                           }
                }
         this.$store.commit('restful_api',x)
              break;
          case "视频学堂":
              // code block
          console.info('spxt');
          var x = {
               actionName:'QueryHaveBoughtKnowledgeGroup',
               url: 'baseapi',
                postData: {
                             'type':'2', //类型1.文字课程，2.查询学习计划（为空时查询全部）
                             'tagId':'SPXT' //标签ID
                           }
                }
         this.$store.commit('restful_api',x)
              break;
          case "知识学堂":
              // code block
          console.info('zsxt');
          var x = {
               actionName:'QueryHaveBoughtKnowledgeGroup',
               url: 'baseapi',
                postData: {
                             'type':'2', //类型1.文字课程，2.查询学习计划（为空时查询全部）
                             'tagId':'ZSXT' //标签ID
                           }
                }
         this.$store.commit('restful_api',x)
              break;
          case "视频学堂":
              // code block
          console.info('spxt');
          var x = {
               actionName:'QueryHaveBoughtKnowledgeGroup',
               url: 'baseapi',
                postData: {
                             'type':'2', //类型1.文字课程，2.查询学习计划（为空时查询全部）
                             'tagId':'SPXT' //标签ID
                           }
                }
         this.$store.commit('restful_api',x)
              break;
          default:
          console.info(44);
      }
    },
    gobuy(a,b){
      alert(33)
      console.info(b);
       this.$store.commit('restful_api',this.broughtlist)
    }
  },
  beforeDestory () {

  },
  watch: {
  },
  computed: {
    queryhold() {

    },
    all_bought(){
      return this.$store.getters.all_restful_QueryHaveBoughtKnowledgeGroup
    }
  },
  mounted () {
     this.$nextTick(function(){
  Event.listen("brought",(e) =>{
         this.$vux.alert.show({
          title: '未购买',
          content: this.$t(e),
          onShow () {
      console.log('Plugin: I\'m showing')
          },
          onHide () {
      console.log('Plugin: I\'m hiding  now')
          }
      })

  })
     })
     this.handler = () => {
       if(this.path ==='/brought') {
       }
     }
  }
}
</script>

